package cz.cuni.mff.ufal.volk.message;

import cz.cuni.mff.ufal.volk.nabaztag.Led;

/**
 * Sets the color of the given led on the Nabaztag.
 * 
 * @author Bartłomiej Etenkowski
 */
public class SetLedColorMessage implements Message {
  
  /**
   * Creates new {@code SetColorMessage}.
   * 
   * @param led led to be set
   */
  public SetLedColorMessage(Led led, int red, int green, int blue) {
    this.led = led;
    this.red = red;
    this.green = green;
    this.blue = blue;
  }
  
  private final Led led;
  
  private final int red;
  
  private final int green;
  
  private final int blue;

  @Override
  public String getCommand() {
    return "CL";
  }

  @Override
  public String getParameterString() {
    int command = ((int)led.getId() << 24) + (red << 16) + (green << 8) + blue;
    return String.format("0x0%sh", Integer.toHexString(0x10000000 | command).toUpperCase().substring(1));
    //return String.format("0x%s%s%s%sh", toHex(led.getId()), toHex(red), toHex(green), toHex(blue));
  }

}
